package demo6;

import org.springframework.stereotype.Controller;

import java.lang.reflect.Constructor;

public class Demo3 {
    public static void main(String[] args) {
        try {
            Class cls=Class.forName("demo6.Student");
            Constructor c=cls.getDeclaredConstructor();
            //Class对象的newInstance方法只能调用公开的无参构造器
            //Object o=cls.newInstance();
            //System.out.println(o);
            c.setAccessible(true);
            Object o1=c.newInstance();
            Object o2=c.newInstance();
            System.out.println(o1);
            System.out.println(o2);
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
